home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8676 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  27 lines

  1. Newsgroups: comp.lang.pascal.misc,comp.lang.c++,comp.lang.c,comp.lang.pascal.borland
  2. Path: cwi.nl!dik
  3. From: dik@cwi.nl (Dik T. Winter)
  4. Subject: Re: Tough FACTORIAL math problem...
  5. Message-ID: <DnCutM.5ss@cwi.nl>
  6. Sender: news@cwi.nl (The Daily Dross)
  7. Nntp-Posting-Host: chrysant.cwi.nl
  8. Organization: CWI, Amsterdam
  9. References: <4gaucn$cdu@beyond.escape.com> <4gh4cq$8eo@agate.berkeley.edu> <312FFCCF.33209502@armory.com>
  10. Date: Sun, 25 Feb 1996 23:34:33 GMT
  11.  
  12. In article <312FFCCF.33209502@armory.com> Tim Martin <tass@armory.com> writes:
  13.  > BTW-I didn't enter the competition, but I also solved it that particular
  14.  > way...with a little more clumsy approach using strings instead of
  15.  > longints, but the basic concept is the same - you only need to save the
  16.  > last 4 non-zero digits, because you are only ever multiplying the result
  17.  > by something less than 1000.
  18.  
  19. The reason you give is not the true reason.  Multiplying by 625 introduces
  20. 4 new zeros; by pure chance the fifth digit from the rightmost non-zero
  21. digit of 624! is even (it is 0).  If it had been odd you would have found
  22. a wrong result.  Compare: if you multiply 10016 by 625 the last non-zero
  23. digit of the result is 6, if you had only used 0016 you would have found 1.
  24. -- 
  25. dik t. winter, cwi, kruislaan 413, 1098 sj  amsterdam, nederland, +31205924098
  26. home: bovenover 215, 1025 jn  amsterdam, nederland; http://www.cwi.nl/~dik/
  27.